#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

const int N = 1e6+5;
const ll P = 1e9+7;
int _,kmp[N],num[N],len;
char ch[N];

int main(){
	std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("in.in", "r", stdin);
	cin >> _;
	while(_--){
		cin >> (ch+1);
		len = strlen(ch+1);
		rep(i,1,len) kmp[i] = 0;
		int j = 0;
		num[0] = 0 , num[1] = 1;
		rep(i,2,len){
			while(ch[j+1] != ch[i] && j) j = kmp[j];
			if(ch[j+1] == ch[i]) kmp[i] = ++j;
			// cout << "kmp[" << i << "] = " << kmp[i] << "\n";
		}
		rep(i,2,len) num[i] = num[ kmp[i] ] + 1;
		ll ans = 1;
		j = 0;
		rep(i,1,len){
			while(ch[j+1] != ch[i] && j) j = kmp[j];
			if(ch[j+1] == ch[i]) ++j;
			while(i/2 < j) j = kmp[j];
			ans = ans * (ll)(num[j] + 1) % P;
			// cout << "num[" << j << "] = " << num[j] << "\n";
		}
		cout << ans << "\n";
	}
	return 0;
}